<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<html:html>
<head>
<META http-equiv=Pragma content=no-cache>
<META http-equiv=Cache-Control content=no-cache>
<META http-equiv=Expires content=0>
<title><bean:message key="F0504.title"/></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="../../resource/css/style.css" type="text/css">
<script language="javascript" type="text/javascript" src="../../resource/js/util.js"></script>
<script language="javascript" type="text/javascript" src="../../resource/js/AdyhUtil.js"></script>
<script language="javascript" type="text/javascript" src="../../resource/calendar/DCDA_C03.js"></script>
<script language="javascript" type="text/javascript" src="<%=request.getContextPath()%>/resource/js/Validator.js"></script>	
<script type="text/javascript"
		src="<%=request.getContextPath()%>/style/ext/adapter/ext/ext-base.js"></script>
	<script type="text/javascript"
		src="<%=request.getContextPath()%>/style/ext/ext-all.js"></script>
<script language="javascript1.2">

/**重置*/
function ResetMe()
{	
    document.getElementById("contractNumber").className = "MyText";
    document.getElementById("invoiceNumber").className = "MyText";
	document.getElementById("manufacturingOrder").className = "MyText";
    document.getElementById("customersName").className = "MyText";
	document.getElementById("totalAmount").className = "MyText";
	document.getElementById("invoiceDate").className = "MyText";
	document.getElementById("estiCollectDate").className = "MyText";
	document.getElementById("realCollectDate").className = "MyText";

	var objPrompt = document.getElementById("divPrompt");
    objPrompt.style.display = "none";
	objPrompt.innerHTML = "";
}

//保存 判断
function operation1(){
	ResetMe();
	var contractNumber = document.getElementById("contractNumber").value;
	var invoiceNumber = document.getElementById("invoiceNumber").value;
	var manufacturingOrder = document.getElementById("manufacturingOrder").value;
	var customersName = document.getElementById("customersName").value;
	var totalAmount = document.getElementById("totalAmount").value;
	var invoiceDate = document.getElementById("invoiceDate").value;
	var estiCollectDate = document.getElementById("estiCollectDate").value;
	var realCollectDate = document.getElementById("realCollectDate").value;
	
	var submitFlag = true;
	var objPrompt = document.getElementById("divPrompt");
    objPrompt.style.display = "block";
    objPrompt.innerHTML = "";
    
    	if(!isNotNull(Jtrim(contractNumber))){
			objPrompt.innerHTML += "<li><bean:message key="F05.contractNumber"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("contractNumber").className = "MyControlError";
			submitFlag = false;
		}
		else{
			if(isNumber(contractNumber)){
				objPrompt.innerHTML += "<li><bean:message key="F05.contractNumber"/><bean:message key="adyh.error.number"/>！";
				document.getElementById("contractNumber").className = "MyControlError";
				submitFlag = false;
			}
		}
    	
    	if(!isNotNull(Jtrim(invoiceNumber))){
			objPrompt.innerHTML += "<li><bean:message key="F05.invoiceNumber"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("invoiceNumber").className = "MyControlError";
			submitFlag = false;
		}
		else{
			if(isNumber(invoiceNumber)){
				objPrompt.innerHTML += "<li><bean:message key="F05.invoiceNumber"/><bean:message key="adyh.error.number"/>！";
				document.getElementById("invoiceNumber").className = "MyControlError";
				submitFlag = false;
			}
		}
    	
		if(!isNotNull(Jtrim(manufacturingOrder))){
			objPrompt.innerHTML += "<li><bean:message key="common.ManufacturingOrder"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("manufacturingOrder").className = "MyControlError";
			submitFlag = false;
		}
		else{
			if(isNumber(manufacturingOrder)){
				objPrompt.innerHTML += "<li><bean:message key="common.ManufacturingOrder"/><bean:message key="adyh.error.number"/>！";
				document.getElementById("manufacturingOrder").className = "MyControlError";
				submitFlag = false;
			}
		}
	    if(!isNotNull(Jtrim(customersName))){
			objPrompt.innerHTML += "<li><bean:message key="adyh.customerName"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("customersName").className = "MyControlError";
			submitFlag = false;
		}
		
		if(!isNotNull(Jtrim(totalAmount))){
			objPrompt.innerHTML += "<li><bean:message key="F0504.collectMoney"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("totalAmount").className = "MyControlError";
			submitFlag = false;
		}
		else{
			if(isNumber(totalAmount)){
				objPrompt.innerHTML += "<li><bean:message key="F0504.collectMoney"/><bean:message key="adyh.error.number"/>！";
				document.getElementById("totalAmount").className = "MyControlError";
				submitFlag = false;
			}
		}
		
		if(!isNotNull(Jtrim(invoiceDate))){
			objPrompt.innerHTML += "<li><bean:message key="F0503.invoicedDate"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("invoiceDate").className = "MyControlError";
			submitFlag = false;
		}
		if(!isNotNull(Jtrim(estiCollectDate))){
			objPrompt.innerHTML += "<li><bean:message key="F0504.estiCollectDate"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("estiCollectDate").className = "MyControlError";
			submitFlag = false;
		}
		if(!isNotNull(Jtrim(realCollectDate))){
			objPrompt.innerHTML += "<li><bean:message key="F0504.realCollectDate"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("realCollectDate").className = "MyControlError";
			submitFlag = false;
		}

		if(submitFlag==true){
		   if(document.forms[0].layOutType.value=="add"){
	           operation('insert');
	       }else{
	           operation('update');
	       }	
		}	      
}

//动态加载 页面信息
  function initDetail()
  {  		
      	var contractNumber = document.getElementById("contractNumber").value;      	      
   		Ext.Ajax.request(
   		{
		url : 'F0504.do' , 
		params : {operationType:'ajax',id:'contractNumber',contractNumber:contractNumber},
		method: 'POST',
		success: function ( result, request) 
			{
			var reValue = "";
			var reValues = new Array();
			reValue = Jtrim(result.responseText);
			if(reValue ==""){
				alert("没有此订单号！");
				return;
			}
			reValues = reValue.split('*');
			document.forms[0].manufacturingOrder.value = reValues[0]; 
			document.forms[0].totalAmount.value = reValues[1];
			document.forms[0].customersCode.value = reValues[2];
   			document.forms[0].customersName.value = reValues[3];
   			
			},	
		failure: function ( result, request) { 
			alert("<bean:message key="F020106.title"/>");
			} 
		}
		);
  }
  

function ShowFormTitle(strTitle){
	document.write("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"height:26px; background-position: left bottom; background-image: url(../../style/images/FormTitle_A_4.gif); background-repeat: repeat-x;\">");
	document.write("  <tr >");
	document.write("	<td style=\"width:5px; background-position: left bottom; background-image: url(../../style/images/FormTitle_A_1.gif); background-repeat: no-repeat;\">&nbsp;&nbsp;&nbsp;</td>");
	document.write("	<td class=\"FormTitle\" style=\"width:100%; padding-left:5px; padding-top:3px; background-position: left bottom; background-image: url(../../style/images/FormTitle_A_2.gif); background-repeat: no-repeat;\">");
	document.write("		<span id=\"spanFormTitle\" class=\"SpanTitle\">"+ strTitle +"</span>");
	document.write("	</td>");
	document.write("	<td style=\"width:5px; background-position: right bottom; background-image: url(../../style/images/FormTitle_A_3.gif); background-repeat: no-repeat;\">&nbsp;&nbsp;&nbsp;</td>");
    document.write("  </tr>");
	document.write("</table>");
}	

</script>
</head>

<body marginheight="0" marginwidth="0" bottommargin="0" topmargin="0">
<html:form method="post" action="/pages/F05/F0504.do" enctype="multipart/form-data">
<html:hidden property="operationType"/>
<html:hidden property="layOutType" />
<html:hidden property="id"/>
<html:hidden property="customersCode" />
<!--Begin：表单标题-->
<div class="DivBlock">
	<script language="javascript" type="text/javascript">
		ShowFormTitle("<bean:message key="F0504.title"/>");
	</script>
</div>
<!--End：表单标题-->
<!--Begin：表单折叠区块1-->
<div class="DivBlock">
<div class="DivWrap">
  <table  WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
	<tr>	
		<td align="center"><bean:message key="F05.contractNumber"/></td>
		<td><html:text property="contractNumber" styleClass="MyText" onchange="initDetail(this)"/></td>
		<td  align="center"><bean:message key="F05.invoiceNumber"/></td>
		<td><html:text property="invoiceNumber" styleClass="MyText" /></td>		
		<td align="center"><bean:message key="common.ManufacturingOrder"/></td>
		<td><html:text property="manufacturingOrder" styleClass="MyTextReadOnly" readonly="true"/></td>		
	</tr>
	<tr>
		<td align="center"><bean:message key="adyh.customerName"/></td>
		<td><html:text property="customersName" styleClass="MyTextReadOnly" readonly ="true"/></td>		
		<td align="center"><bean:message key="F0504.collectMoney"/></td>
		<td><html:text property="totalAmount" styleClass="MyText"/></td>
		<td align="center">&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
	<tr>
	   <td align="center"><bean:message key="F0503.invoicedDate"/></td>
		<td><html:text property="invoiceDate" styleClass="MyText" onclick="return CalendarClick(this)"/></td>
		<td align="center"><bean:message key="F0504.estiCollectDate"/></td>
		<td><html:text property="estiCollectDate" styleClass="MyText" onclick="return CalendarClick(this)"/></td>
		<td align="center"><bean:message key="F0504.realCollectDate"/></td>
		<td><html:text property="realCollectDate" styleClass="MyText" onclick="return CalendarClick(this)"/></td>
	</tr>
  </table>
</div>
</div>
<!--End：表单折叠区块1-->
<div class="DivBlock">
<div class="DivButton">
  <input type="button" name="Submit1" class="MyButton" value="<bean:message key="common.save"/>" onClick="javascript:operation1();">
  <input type="button" name="Submit2" class="MyButton" value="<bean:message key="common.back"/>" onClick="javascript:operation('back');">
</div>
<div class="DivPrompt" id="divPrompt" style="display:none">
</div>
</div>
<div id="supplier" style="display:block; width:135;position:relative" onmouseleave ="col(this)">							
</div>
</html:form>
</body>
</html:html>